﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WpfStudy.MyControls;

namespace WpfStudy
{
    /// <summary>
    /// ElectronicsWindow.xaml 的交互逻辑
    /// </summary>
    public partial class ElectronicsWindowUserDT : Window
    {
        public ElectronicsWindowUserDT()
        {
            InitializeComponent();
            InitElectronicsList();
        }

        private void InitElectronicsList()
        {
            List<Electronics> eleList = new List<Electronics>()
            {
                new Electronics(){Name="Apple Watch Series 6智能手表",Year="2020",Price="3499",Type="Watch"},
                new Electronics(){Name="戴尔(DELL)游匣G15-5511",Year="2021",Price="8999",Type="computer"},
                new Electronics(){Name="HUAWEI-mate40",Year="2020",Price="4599",Type="phone"},
            };

            listBoxEle.ItemsSource = eleList;
        }

    }


    public class ProductNameToPhotoPath : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return $@"../Resource/image/{value.ToString()}.jpg";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class ProductTypeToIconPath : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return $@"../Resource/image/icon/{value.ToString()}Icon.png";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

}
